import { MessageBox,Message } from 'element-ui'
//树状结构 去掉空数组
export function delateMenuChildren(arr) {
  if (arr.length > 0) {
    for (let i in arr) {
      if (arr[i].children && arr[i].children.length > 0) {
        delateMenuChildren(arr[i].children);
      } else {
        delete arr[i].children;
      }
    }
  }
  return arr;
}
// confirm确认弹框提示封装
export function confirm(text,title = '提示'){
  return new Promise((resolve, reject) => {
    MessageBox.confirm(text, title, {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    }).then(_ => {
        resolve(true)
    }).catch(_ => {
      // Message.info('已取消')
      reject(false)
    })
  }).catch(err => {
    console.log(err)
  })
}

 //判断一个数组中是否有重复项
 export function isRepeat (arr) {
  var hash = {};
  for (var i in arr) {
    if (hash[arr[i].month]) {
      return true;
    }
    hash[arr[i].month] = true;
  }
  return false;
}
